// pages/taskStop/taskStop.js
const app = getApp();
let taskId;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    employList: [{
      key: 5,
      name: '张三',
      level:'高级佣兵',
    },{
      key: 3,
      name: '李四',
      level:'高级佣兵',
    },{
      key: 2,
      name: '王五',
      level:'高级佣兵',
      }],
    active:-1,
    memberId:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self = this;
    taskId = options.taskId;
    wx.request({
      url:app.globalData.prefix+"/taskAction/publishTaskInfo.do?taskId="+taskId+"&openId="+app.globalData.userInfo.openId,
      success:function(res){
        self.setData({task:res.data.result.task});
        self.setData({takeList:res.data.result.takeList});
        console.log(res.data.result);
      }
    });
  },

  changeIndex(e) {
    console.log(e);
    this.setData({
      active:e.currentTarget.dataset.index,
      memberId:e.currentTarget.dataset.memberid
    });
  },
  downShelf() {
    let self = this;
    console.log("选定佣兵编号："+this.data.memberId);
    wx.request({
      url:app.globalData.prefix+"/taskAction/dismountTask.do?taskId="+taskId+"&memberId="+self.data.memberId,
      success:function(res){
        if(res.data.status!='00'){
          wx.$showToast(res.data.errorMsg);
          return;
        }
        wx.$showToast("下架成功");
      }
    });
    wx.navigateTo({
      url: '../mySelfTask/mySelfTask',
    })
  }
})